package com.study.concurrent.C_ThreadSynchronizationHelperClass.h_RunningOfConcurrentPhaseTasks;

import java.util.concurrent.Phaser;

/**
 * Created by 赵超 on 2017/3/26.
 */
public class Main {
    public static void main(String[] args) {
        Phaser phaser = new Phaser(3);

        FileSearch windowSearch = new FileSearch("C:\\Windows", "log", phaser);
        FileSearch programSearch = new FileSearch("C:\\Program Files", "log", phaser);
        FileSearch documentSearch = new FileSearch("C:\\Documents And Settings", "log", phaser);

        Thread windowSearchThread = new Thread(windowSearch, "windowSearchThread");
        windowSearchThread.start();
        Thread programSearchThread = new Thread(programSearch, "programSearchThread");
        programSearchThread.start();
        Thread documentSearchThread = new Thread(documentSearch, "documentSearchThread");
        documentSearchThread.start();

        try {
            windowSearchThread.join();
            programSearchThread.join();
            documentSearchThread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.printf("Phaser对象是否死亡：%s\n", phaser.isTerminated());
    }
}
